package cn.sinata.wanglin.mine.activity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.text.TextUtils;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.TextView;

import com.google.gson.JsonObject;
import com.xilada.xldutils.activitys.TitleActivity;
import com.xilada.xldutils.activitys.WebViewActivity;
import com.xilada.xldutils.utils.SharedPreferencesUtils;

import cn.sinata.wanglin.R;
import cn.sinata.wanglin.commonutils.Constant;
import cn.sinata.wanglin.model.Message;
import cn.sinata.wanglin.model.NewsinfoDetails;
import cn.sinata.wanglin.net.HttpManager;
import cn.sinata.wanglin.net.model.util.ResultDataSubscriber;
import cn.sinata.wanglin.utils.RelativeDateFormat;

/**
 * 系统消息详情页面
 */
public class MessageDetailActivity extends TitleActivity {

    private WebView webView;
    private View loadingView;
    private TextView tv_title;
    private TextView tv_fromandtiem;
    private Message message;
    @Override
    protected int setContentId() {
        return R.layout.activity_sysemmessage_details;

    }
    @SuppressLint("SetJavaScriptEnabled")
    @Override
    protected void initView() {
        super.initView();
        setTitle("公告详情");
        webView = bind(R.id.webView);
        loadingView = bind(R.id.ll_loading);
        tv_title = bind(R.id.tv_title);
        tv_fromandtiem = bind(R.id.tv_fromandtiem);
        message = (Message) getIntent().getSerializableExtra("message");
        tv_title.setText(message.getTitle());
        tv_fromandtiem.setText(RelativeDateFormat.format(message.getCreate_date()));
        WebSettings settings = webView.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setJavaScriptCanOpenWindowsAutomatically(true);
        settings.setDefaultTextEncodingName("utf-8");
        webView.loadDataWithBaseURL(null,message.getNotice_content(), "text/html", "utf-8", null);

    }

    protected boolean resetTitle(){
        return false;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        //webView回收,部分手机无效
        if (webView!=null){
            webView.stopLoading();
            webView.removeAllViews();
            webView.destroy();
        }
        if (loadingView !=null)
            loadingView = null;
    }

}